NOTE
3.5 Redis bigkey
What a Redis big key is, its risks, how to find and delete it, and the basic mitigation of splitting it into smaller keys.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is a Big Key?
- This is about the value:
- string type: generally considered big when it exceeds 10 KB;
- other types: too many elements.
2. Risks of a Big Key
- Timeout and blocking: operating on a big key is time-consuming.
- Uneven memory allocation: for example, under Redis Cluster mode.
- Is the bottleneck for reading/writing a big key CPU or bandwidth? Below xx bandwidth, bandwidth becomes full first; above xx, CPU becomes full first.
3. How to Find a Big Key
scan + debug object: on a replica node, usescanfor incremental scanning, then usedebug objectto calculate whether each key’sserializedlengthattribute is too large.redis-cliprovides--bigkeys, for example:redis-cli -h <hostip> -a <password> --bigkeys.
4. How to Delete a Big Key
- string: use
del. - others:
hscan + hdel + del.
5. How to Solve a Big Key
5.1. Split It into Smaller Keys
6. References
- A Detailed Explanation of the Detection and Processing of BigKey and HotKey in Redis - Alibaba Cloud Community
- How to Handle Hot Keys and Big Keys in a Redis Cluster - Tencent Cloud Community
- Tencent Cloud Database Redis: Query Instance Big Keys - API Documentation
- Discover and Handle Redis Big Keys and Hot Keys
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub